//
// Created by 17775 on 2024/9/19.
//

#ifndef RAYCI_LIVEMODE_2D_VIEW_SETTINGS_H
#define RAYCI_LIVEMODE_2D_VIEW_SETTINGS_H

#include <QCheckBox>
#include <QRadioButton>
#include <QLabel>
#include <QDockWidget>
#include <QTreeWidgetItem>
#include <QButtonGroup>


QT_BEGIN_NAMESPACE
namespace Ui { class LiveMode_2D_View_Settings; }
QT_END_NAMESPACE

class LiveMode_2D_View_Settings : public QDockWidget {
Q_OBJECT

signals:
    // AOI
    void setAOIShape(int nShape);
    void setPosition_px(double dPosX, double dPosY);
    void setAOISize(double dMajor, double dMinor, double dPhi);

    // Coord.System
    void setImageX(bool isXImageOrAOI, int index);
    void setLeftX(bool isLeftOrTop, int index);
    void setCoordSystemMode(int iMode);
    void setUserDefinedPosition(double xPos, double yPos);
    void Show_Or_Hide_Aoi(int index,bool show);
    void mainAOIChanged(int index);
    void AdjustAoiToCenterSignal(bool check);
    void setVisualization(bool check);
    void Coordinate_Arrow_Convert(int index);

public:
    explicit LiveMode_2D_View_Settings(QWidget *parent = nullptr);
    ~LiveMode_2D_View_Settings() override;
    void setWindowTitleName(const QString& name);

    void setStepByUnit(const QString& unit, double sizeX, double sizeY);
    double conversion(QString unit, double size, int a = 1);
    void setPositionSize(double dPositionX_px, double dPositionY_px, double dMajor_px, double dMinor_px, double dAzimuthAngle_px, int nShape, int nMethod, bool bActive);
    void changePositionSizeUnit(const QString& unit);
    void setPhi(double phi);
    void setUserDefinedPositionX(double xPos);
    void setUserDefinedPositionY(double yPos);
    void updateEnabledAoi(int index, bool bEnable);
    void updateMainAOIUI(int index);
    void AdjustAoiToCenter();
    static QColor getColorForIndex(int index);
    void showCoordSyem(bool show);


private:
    Ui::LiveMode_2D_View_Settings *ui;
    QList<QTreeWidgetItem*> items= QList<QTreeWidgetItem*>();
    QList<QCheckBox*> cBoxes;
    QList<QRadioButton*> rBtn;
    void initView();



bool changeUnable = false;
    QButtonGroup *systemModeGroup = nullptr;
    double realXPos = 0, realYPos = 0;
};


#endif //RAYCI_LIVEMODE_2D_VIEW_SETTINGS_H
